void high(){

if(INTCONbits.TMR0IF){
A++;
INTCONbits.TMR0IF = 0;

if(TRISCbits.TRISC4 == 0){
nn = n;
B = 2048 - nn;
BB = B;
}

}
}


void low(){

if(INTCON3bits.INT1IF){
TRISCbits.TRISC4 = 0;
PORTCbits.RC4 = 0;

TL = TMR0L;
AA = A;
INTCON3bits.INT1IF = 0;


if(PORTCbits.RC7 == 0){

for(j = 0; j < 2048; j++){
PORTCbits.RC4 = 1;
Delay1TCY();
PORTCbits.RC4 = 0;
Delay1TCY();
n++;
}

FFF = (AA*256 + TL)*8 + BB;

Delay10TCYx(1);

for(j = 0; j < nn; j++){
PORTCbits.RC4 = 1;
Delay1TCY();
PORTCbits.RC4 = 0;
Delay1TCY();
}
}

if((PORTAbits.RA3 == 0) || (PORTCbits.RC3 == 0)){
FFF = AA*256 + TL;
}

n = 0; A = 0; TMR0L = 0; BB = 0;

PORTCbits.RC0 = 1;
TRISCbits.TRISC4 = 1;
Delay1TCY();
PORTCbits.RC0 = 0;
}
}